home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
cgraphix
/
kdrawln.c
< prev
next >
Wrap
Text File
|
1986-05-08
|
2KB
|
86 lines
/* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
#include <stdio.h>
#define EXTERN extern
#include <typedef.h>
void DrawLineDirect(x1,y1,x2,y2)
int x1, y1, x2, y2;
{
int x, y, DeltaX, DeltaY, XStep, YStep, direction;
x = x1;
y = y1;
XStep = 1;
YStep = 1;
if (x1 > x2)
XStep = -1;
if (y1 > y2)
YStep = -1;
DeltaX = iabs(x2-x1);
DeltaY = iabs(y2-y1);
if (DeltaX == 0)
direction = -1;
else
direction = 0;
while (!((x == x2) && (y == y2))) {
if (LineStyleGlb == 0)
DP(x,y);
else {
CntGlb = (CntGlb+1) & 7;
if (LineStyleArrayGlb[CntGlb])
DP(x,y);
}
if (direction < 0) {
y += YStep;
direction += DeltaX;
}
else {
x += XStep;
direction -= DeltaY;
}
}
}
void DrawLine(x1, y1, x2, y2)
double x1, y1, x2, y2;
{
int X1Loc, Y1Loc, X2Loc, Y2Loc;
if (DirectModeGlb)
DrawLineDirect((int)x1, (int)y1, (int)x2, (int)y2);
else {
X1Loc = WindowX(x1);
Y1Loc = WindowY(y1);
X2Loc = WindowX(x2);
Y2Loc = WindowY(y2);
if (clip(&X1Loc, &Y1Loc, &X2Loc, &Y2Loc))
DrawLineDirect(X1Loc, Y1Loc, X2Loc, Y2Loc);
}
}
void DrawLineClipped(x1, y1, x2, y2)
int x1, y1, x2, y2;
{
if (clip(&x1, &y1, &x2, &y2))
DrawLine((double)x1, (double)y1, (double)x2, (double)y2);
}
void DrawLinW(X1, Y1, X2, Y2, DirectModeLoc)
int X1, Y1, X2, Y2, DirectModeLoc;
{
int DrawIt;
DrawIt = DirectModeLoc;
if (!DrawIt) {
DrawIt = clip(&X1, &Y1, &X2, &Y2);
}
if (DrawIt)
DrawLine((double)X1, (double)Y1, (double)X2, (double)Y2);
}